package com.jrtc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jrtc.base.entity.bo.Doctorservice;
import com.jrtc.dao.DoctorserviceDao;
import com.jrtc.service.DoctorserviceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 医事服务表(Doctorservice)表服务实现类
 *
 * @author makejava
 * @since 2022-03-21 17:34:12
 */
@Service("doctorserviceService")
public class DoctorserviceServiceImpl implements DoctorserviceService
{
    @Resource
    private DoctorserviceDao doctorserviceDao;

    /**
     * 通过ID查询单条数据
     *
     * @param doctorserviceId 主键
     * @return 实例对象
     */
    @Override
    public Doctorservice queryById(Integer doctorserviceId) {
        return this.doctorserviceDao.queryById(doctorserviceId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Doctorservice> queryAllByLimit(int offset, int limit) {
        return this.doctorserviceDao.queryAllByLimit(offset, limit);
    }

    @Override
    public IPage<Doctorservice> queryDoctorserviceList(Doctorservice doctorservice)
    {
        com.baomidou.mybatisplus.extension.plugins.pagination.Page<Doctorservice> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(doctorservice.getPageNo(), doctorservice.getPageSize());
        IPage<Doctorservice> doctorservicePage = this.doctorserviceDao.queryDoctorserviceList(page, doctorservice);
        return doctorservicePage;
    }
    /**
     * 新增数据
     *
     * @param doctorservice 实例对象
     * @return 实例对象
     */
    @Override
    public Doctorservice insert(Doctorservice doctorservice) {
        this.doctorserviceDao.insert(doctorservice);
        return doctorservice;
    }

    /**
     * 修改数据
     *
     * @param doctorservice 实例对象
     * @return 实例对象
     */
    @Override
    public Doctorservice update(Doctorservice doctorservice) {
        this.doctorserviceDao.update(doctorservice);
        return this.queryById(doctorservice.getDoctorserviceId());
    }

    /**
     * 通过主键删除数据
     *
     * @param doctorserviceId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer doctorserviceId) {
        return this.doctorserviceDao.deleteById(doctorserviceId) > 0;
    }
}